package model;

/**
 * This Enumeration represents all the timeslots
 * that employees may be scheduled in and will be
 * used for easy comparisons during schedule
 * construction.
 * 
 * @author Tristan D. Boucher
 * @version Commit #22 9/14/2013
 *
 */
public enum Day 
{

  /**
   * Monday.
   */
  MONDAY(0), 

  /**
   * Tuesday.
   */
  TUESDAY(1), 

  /**
   * Wednesday.
   */
  WEDNESDAY(2), 

  /**
   * Thursday.
   */
  THURSDAY(3), 

  /**
   * Friday.
   */
  FRIDAY(4),

  /**
   * Saturday.
   */
  SATURDAY(5),

  /**
   * Sunday.
   */
  SUNDAY(6);

  /**
   *  The constant that lists all of the available days.
   */
  private static final Day[] MY_DAYS = {Day.MONDAY,
                                        Day.TUESDAY,
                                        Day.WEDNESDAY,
                                        Day.THURSDAY,
                                        Day.FRIDAY,
                                        Day.SATURDAY};
  
  /**
   * The number corresponding to a particular day. Computer Scientists start at 0.
   */
  private int my_index;

  // Constructor

  /**
   * Constructs a new Day with the specified index.
   * 
   * @param the_index the index of the day.
   */
  private Day(final int the_index)
  {
    my_index = the_index;
  }

  // Instance Methods

  /**
   * Returns the Day represented by a particular number.
   * 
   * @param the_index The index of the day to return. 
   * @return the day represented by the given index. If the
   * index is not recognizable, the default is Sunday.
   */
  public static Day valueOf(final char the_index)
  {
    Day result = SUNDAY;

    for (Day day : Day.values())
    {
      if (day.my_index == the_index)
      {
        result = day;
        break;
      }
    }

    return result;
  }

  /**
   * Returns all of the timeslot types in a timeslot array.
   * 
   * @return MY_SLOTS all the timeslot variables.
   */
  public static Day[] getDays()
  {
    return MY_DAYS.clone();
  }
  
  /** 
   * Returns a String representation of this Day such as "Saturday (5)".
   * 
   * @return a String representation of this Day.
   */
  public String toString()
  {
    return super.toString() + " (" + my_index + ")";
  }
}
// end of Enumeration Day